define([
        'app/utils/WebUtils',
        'app/service/GeneralServices',
        'underscore',
        'app/utils/AMUICookieUtils',
        'app/utils/CommonUtils'
        
        
        ], function (
        WebUtils,
        gs,
        _,
        AMUICookieUtils
    ) {
	
	var opt ={};
	var p1 = {};
	
	opt = AMUICookieUtils.initializePage();
	p1 = AMUICookieUtils.initializePage();
	opt.roomuuid = $.getUrlParam("roomuuid");
	p1.roomuuid = $.getUrlParam("roomuuid"); 
	gs.wjt_chairinvite_init(p1, function(resp){
		if(resp.status == "500"){
			WebUtils.alert("连接错误，请刷新页面重试！");	
			return;
		}
		
		opt.navi_main = "邀请主讲人";
		opt.navi_sub = "请选择要成为【"+resp.result.roomname+"】的主讲嘉宾";
		
		console.log(resp.result);
		WebUtils.adminPageInt(opt);
		

		$(".wjt-admin-list").html("");
		
		for(var i = 0; i < resp.result.chairs.length; i++){
			var item = resp.result.chairs[i];
			
			var el = $(
					'<tr>'+
					'<td><img src="'+$.val_trim(item.headimgurl)+'" style="width:60px;height:60px;"></td>'+
		            '<td>'+$.val_trim(item.name)+'</td>'+
		            '<td>'+$.val_trim(item.email)+'</td> '+
		            '<td>'+$.val_trim(item.tel)+'</td> '+
		            '<td>'+
		              '<div class="am-dropdown" data-am-dropdown="">'+
		                '<button class="am-btn am-btn-default am-btn-xs am-dropdown-toggle" data-am-dropdown-toggle=""><span class="am-icon-cog"></span> <span class="am-icon-caret-down"></span></button>'+
		                '<ul class="am-dropdown-content">'+
		                  '<li><a class="wjt-room-chair-delete" data-uuid="'+item.uuid+'">删除</a></li>'+
		                '</ul>'+
		              '</div>'+
		            '</td>'+
		          '</tr>');
			$(".wjt-admin-list").append(el);
		}
		//下拉栏
		$('.am-dropdown').dropdown();
		//弹出框
		$('.wjt-am-popover').popover();
		
		
		$(".wjt-room-chair-delete").click(function(){
			
			var useruuid = $(this).data("uuid");
			var roomuuid = opt.roomuuid;
			var m ={
				roomuuid: roomuuid,
				useruuid: useruuid
			};
			gs.wjt_removechair(m, function(resp){
				if(resp.status == "500"){
					if($.isNullStr(resp.result)){
						WebUtils.alert("操作没成功，请重试！");	
						return;
					}else{
						WebUtils.alert(resp.result);	
						return;
					}
				}
				$.refreshPage();
			});
			
		});

		$("#wjt-room-addchair").click(function(){
			$("#wjt_room_chair_invite_dialog").modal();
		});
		
		$("#wjt_room_chair_invite_search").click(function(){
			var email = $.val_trim($("#wjt_room_chair_invite_input").val());
			var m ={
				roomuuid: opt.roomuuid,
				email: email
			};
			gs.wjt_addchair(m, function(resp){
				if(resp.status == "500"){
					if($.isNullStr(resp.result)){
						WebUtils.alert("操作没成功，请重试！");	
						return;
					}else{
						WebUtils.alert(resp.result);	
						return;
					}
				}
				$.refreshPage();
			});
			
		});
	});
	
	
	//tab1
	
	
	return;
});